#include <iostream>
#include <vector> 
using namespace std;
class testDemo
{
public:
    testDemo(int num):num(num){
        std::cout << "调用构造函数" << endl;
    }
    testDemo(const testDemo& other) :num(other.num) {
        std::cout << "调用拷贝构造函数" << endl;
    }
    testDemo(testDemo&& other) :num(other.num) {
        std::cout << "调用移动构造函数" << endl;
    }
	void setNumAdd(){
		num++;
	}
	void show()const{
		cout<<num<<endl;
	}
private:
    int num;
};
int main()
{
    cout << "emplace_back:" << endl;
    std::vector<testDemo> demo1;
	//testDemo td1(1);
    //demo1.emplace_back(move(td1));
	demo1.emplace_back(testDemo(11));
	//td1.setNumAdd();
	//demo1.at(0).show();
	
	
    cout << "push_back:" << endl;
	//testDemo td2(2);
    std::vector<testDemo> demo2;
    demo2.push_back(testDemo(2));
	
	//testDemo td3(3);
	//testDemo td33(td3);
}
//最新测试g++,emplace_back、push_back结果一致
//告诉编译器不要优化，需要看过程：-fno-elide-constructors
//g++ -std=c++11 -fno-elide-constructors  vector_test.c -o vector_test.out